package com.ruoyi.training.service.impl;

import java.util.List;

import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.common.security.utils.SecurityUtils;
import com.ruoyi.training.domain.TrainingClass;
import com.ruoyi.training.mapper.TrainingClassMapper;
import com.ruoyi.training.util.xuehua.SnowflakeIdUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.training.mapper.ClassPaymentSettlementMapper;
import com.ruoyi.training.domain.ClassPaymentSettlement;
import com.ruoyi.training.service.IClassPaymentSettlementService;

/**
 * 班级费用结算Service业务层处理
 *
 * @author lqx
 * @date 2025-10-30
 */
@Service
public class ClassPaymentSettlementServiceImpl implements IClassPaymentSettlementService {

    private static final SnowflakeIdUtils snowflake = new SnowflakeIdUtils(5, 8);

    @Autowired
    private ClassPaymentSettlementMapper classPaymentSettlementMapper;

    @Autowired
    private TrainingClassMapper trainingClassMapper;

    /**
     * 查询班级费用结算
     *
     * @param classPaymentSettlementId 班级费用结算主键
     * @return 班级费用结算
     */
    @Override
    public ClassPaymentSettlement selectClassPaymentSettlementByClassPaymentSettlementId(String classPaymentSettlementId) {
        return classPaymentSettlementMapper.selectClassPaymentSettlementByClassPaymentSettlementId(classPaymentSettlementId);
    }

    /**
     * 查询班级费用结算列表
     *
     * @param classPaymentSettlement 班级费用结算
     * @return 班级费用结算
     */
    @Override
    public List<ClassPaymentSettlement> selectClassPaymentSettlementList(ClassPaymentSettlement classPaymentSettlement) {
        return classPaymentSettlementMapper.selectClassPaymentSettlementList(classPaymentSettlement);
    }

    /**
     * 新增班级费用结算
     *
     * @param classPaymentSettlement 班级费用结算
     * @return 结果
     */
    @Override
    public int insertClassPaymentSettlement(ClassPaymentSettlement classPaymentSettlement) {
        classPaymentSettlement.setClassPaymentSettlementId(String.valueOf(snowflake.nextId()));
        classPaymentSettlement.setCreateBy(SecurityUtils.getLoginUser().getSysUser().getNickName());
        classPaymentSettlement.setCreateTime(DateUtils.getNowDate());
        return classPaymentSettlementMapper.insertClassPaymentSettlement(classPaymentSettlement);
    }

    /**
     * 修改班级费用结算
     *
     * @param classPaymentSettlement 班级费用结算
     * @return 结果
     */
    @Override
    public int updateClassPaymentSettlement(ClassPaymentSettlement classPaymentSettlement) {
        classPaymentSettlement.setUpdateTime(DateUtils.getNowDate());
        return classPaymentSettlementMapper.updateClassPaymentSettlement(classPaymentSettlement);
    }

    /**
     * 批量删除班级费用结算
     *
     * @param classPaymentSettlementIds 需要删除的班级费用结算主键
     * @return 结果
     */
    @Override
    public int deleteClassPaymentSettlementByClassPaymentSettlementIds(String[] classPaymentSettlementIds) {
        return classPaymentSettlementMapper.deleteClassPaymentSettlementByClassPaymentSettlementIds(classPaymentSettlementIds);
    }

    /**
     * 删除班级费用结算信息
     *
     * @param classPaymentSettlementId 班级费用结算主键
     * @return 结果
     */
    @Override
    public int deleteClassPaymentSettlementByClassPaymentSettlementId(String classPaymentSettlementId) {
        return classPaymentSettlementMapper.deleteClassPaymentSettlementByClassPaymentSettlementId(classPaymentSettlementId);
    }
}
